<!-- components/StudentHeader.vue -->
<template>
  <div class="student-header">
    <div class="student-avatar">
      <el-avatar :size="80" :src="props.studentInfo.avatar || ''">
        {{ props.studentInfo.name ? props.studentInfo.name.charAt(0) : 'S' }}
      </el-avatar>
    </div>
    <div class="student-basic-info">
      <div class="student-name-row">
        <h2>{{ props.studentInfo.name || '学生姓名' }}</h2>
        <span class="register-time">注册: {{ props.studentInfo.registerTime || '--' }}</span>
      </div>
      <div class="student-meta">
        <span class="class-info">{{ props.studentInfo.classInfo || '--' }}</span>
        <span class="divider">|</span>
        <span class="school-info">{{ props.studentInfo.school || '--' }}</span>
      </div>
      <div class="student-stats">
        <div class="stat-item">
          <span class="stat-label">学号:</span>
          <span class="stat-value">{{ props.studentInfo.studentId || '--' }}</span>
        </div>
        <div class="stat-item">
          <span class="stat-label">活跃度:</span>
          <span class="stat-value">{{ props.studentInfo.activityLevel || '--' }}</span>
        </div>
        <div class="stat-item">
          <span class="stat-label">在线时长:</span>
          <span class="stat-value">{{ props.studentInfo.onlineTime || '--' }}</span>
        </div>
        <div class="stat-item">
          <span class="stat-label">最近登录:</span>
          <span class="stat-value">{{ props.studentInfo.lastLogin || '--' }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
interface StudentInfo {
  name: string
  avatar: string | null
  registerTime: string
  classInfo: string
  school: string
  activityLevel: string
  onlineTime: string
  lastLogin: string
  studentId: string
}

const props = defineProps<{
  studentInfo: StudentInfo
}>()
</script>

<style scoped>
.student-header {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #ebeef5;
}

.student-avatar {
  margin-right: 20px;
}

.student-basic-info {
  flex: 1;
}

.student-name-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.student-name-row h2 {
  margin: 0;
  margin-right: 20px;
  font-size: 24px;
  color: #303133;
}

.register-time {
  color: #909399;
  font-size: 14px;
}

.student-meta {
  margin-bottom: 15px;
}

.class-info {
  color: #409EFF;
  font-weight: 500;
}

.divider {
  margin: 0 12px;
  color: #dcdfe6;
}

.school-info {
  color: #606266;
}

.student-stats {
  display: flex;
  gap: 30px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 12px;
  color: #909399;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 16px;
  font-weight: 500;
  color: #303133;
}
</style>
